package com.zgscwjm.taobaphelper;

import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

import com.zgscwjm.taobaphelper.exutils.StringUtils;
import com.zgscwjm.taobaphelper.xp.FileManager;

/**
 * Created by zgscwjm on 17-3-1.
 * 对应原来be
 */
public class click_startservice implements View.OnClickListener {
    final MainActivity mainActivity;

    public click_startservice(MainActivity mainActivity) {
        this.mainActivity = mainActivity;
    }

    @Override
    public void onClick(View v) {
        if (this.mainActivity.checkInputMethod()){
            if (StringUtils.isEmpty(mainActivity.getTaoBaoVersionName(mainActivity))){
                this.mainActivity.tv_errorTip.setText("请先安装手机淘宝!!!");
                return;
            }else if (! this.mainActivity.D){
                this.mainActivity.tv_errorTip.setText("应用正在匹配手机中...请再等待几秒钟!!!!");
                return;
            }else if (StringUtils.isEmpty(FileManager.readContent(FileManager.inputTypePath))){
                this.mainActivity.tv_errorTip.setText("写入配置失败!");
                return;
            }else{

                // TODO: 17-3-1 这里就是启动应用的关键逻辑的开始
                this.mainActivity.a();
                this.mainActivity.b();
                this.mainActivity.c(this.mainActivity);
                return;
            }
        }
        ((InputMethodManager)this.mainActivity.getSystemService(Context.INPUT_METHOD_SERVICE)).showInputMethodPicker();
    }
}
